using System;
using System.Security.Principal;

namespace eduSrc.Models
{
    [Serializable]
    public class User : IPrincipal
    {
        #region Private Fields
        private string[] _roles = null;
        private IIdentity _identity = null;

        private int _id = 0;
        private String _userName = String.Empty;
        private String _password = String.Empty;
        private int _sex = 0;
        private String _email = String.Empty;
        private Nullable<DateTime> _birthday = null;
        private String _telephone = String.Empty;
        private int _logonNums = 0;
        private DateTime _lastloginDate = DateTime.Now;
        private int _lockEnable = 0;
        private long _permission = 0x0000000000000000;
        private DateTime _recordDate = DateTime.Now;
        private int _bbsUserID = 0;

        #endregion

        #region Properties

        public int BbsUserID
        {
            set { _bbsUserID = value; }
            get { return _bbsUserID; }
        }

        public IIdentity Identity
        {
            get { return _identity; }
        }

        public bool IsInRole(string role)
        {
            return Array.IndexOf(_roles, role) >= 0;
        }

        public int ID
        {
            set { _id = value; }
            get { return _id; }
        }

        public String UserName
        {
            set { _userName = value; }
            get { return _userName; }
        }

        public String Password
        {
            set { _password = value; }
            get { return _password; }
        }

        public int Sex
        {
            set { _sex = value; }
            get { return _sex; }
        }

        public String Email
        {
            set { _email = value; }
            get { return _email; }
        }

        public Nullable<DateTime> Birthday
        {
            set { _birthday = value; }
            get { return _birthday; }
        }

        public String Telephone
        {
            set { _telephone = value; }
            get { return _telephone; }
        }

        public int LogonNums
        {
            set { _logonNums = value; }
            get { return _logonNums; }
        }

        public DateTime LastLoginDate
        {
            set { _lastloginDate = value; }
            get { return _lastloginDate; }
        }

        public int LockEnable
        {
            set { _lockEnable = value; }
            get { return _lockEnable; }
        }

        public long Permission
        {
            set { _permission = value; }
            get { return _permission; }
        }

        public DateTime RecordDate
        {
            set { _recordDate = value; }
            get { return _recordDate; }
        }

        #endregion
    }
}
